package com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.Address;
import com.bean.PageBean;
import com.serve.AddressService;
import com.serveImple.AddressServiceImpl;

/**
 * Servlet implementation class AddressShowServlet
 */
@WebServlet("/AddressShowServlet")
public class AddressShowServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddressShowServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int defaultPage=1;		
		//处理从页面分页请求的当前页		
		PageBean pb=new PageBean();
		pb.setCurrentPage(defaultPage); //默认获取第一页的数据
		

		AddressService addressservice=new AddressServiceImpl();
		List<Address> addresslist=addressservice.show(pb);
		System.out.println(addresslist);
		request.setAttribute("pb",pb);
		request.setAttribute("addresslist",addresslist);
		System.out.println("你很烦");
		//转发
		request.getRequestDispatcher("easybuy/address2.jsp").forward(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
